package com.study.strategy;
import java.util.List;

/**
 * @Author tanglingyu
 * @Date: 2021/05/07/ 18:47
 * @Description
 */
public abstract class AbstractStrategyFactory implements Strategy {

  private final List<Animal> strategyList;

  public AbstractStrategyFactory(List<Animal> strategyList) {
    this.strategyList = strategyList;
  }

  @Override
  public Animal create(int code) {
    return strategyList.stream().filter(animal -> {
      if (animal.getCategory() == code) {
        return true;
      }
      return false;
    }).findFirst().orElse(null);
  }
}
